home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
redakcyjne
/
programy
/
Tlen 6.0.1.12 pl
/
tleninst60112.exe
/
sdk
/
Plugin_src
/
propertieswindow-vc
/
demoplugin.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2006-09-18
|
6KB
|
241 lines
// demoplugin.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "../../TlenSources/plugin/plugin_struct.h"
#include "../../TlenSources/plugin/plugin_protocol_defs.h"
#include "../../TlenSources/plugin/plugin_options.h"
#include "../../TlenSources/plugin/plugin_propertieswindow.h"
#include "AggressiveOptimize.h"
HINSTANCE hInst;
TLENPLUGINFUNCTIONS *tlen_functions;
HWND prop_page = NULL;
HBITMAP icon1;
COLORREF bgColor;
HBRUSH hBrush;
HANDLE AddPropertiesPageHookHandle;
TLENPLUGININFO pluginInfo={
sizeof(TLENPLUGININFO),
"Demonstracja property page - VC++",
PLUGIN_API_VERSION,
MAKE_DWORD_VERSION(1,2,3,4),
"Opis pluginu",
"⌐ Prawa autorskie",
"Producent",
"E@mail",
"http://www",
0,
0,
0,
0
};
extern "C" __declspec(dllexport) TLENPLUGININFO* GetPluginInfo(DWORD TlenVersion);
extern "C" __declspec(dllexport) int LoadPlugin(TLENPLUGINFUNCTIONS *tlen_functions);
extern "C" __declspec(dllexport) int UnloadPlugin(void);
int prefDialog(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message) {
case WM_INITDIALOG:
{
tlen_functions->CallTlenFunction(hInst, TLEN_ADD_DIALOG_HANDLE, (WPARAM) hWnd, NULL);
hBrush=::CreateSolidBrush(bgColor);
break;
}
case WM_ERASEBKGND:
{
RECT rc;
::GetClientRect(hWnd, &rc);
HDC hdc= (HDC) wparam;
FillRect(hdc,&rc,hBrush);
return true;
}
case WM_CTLCOLORSTATIC:
{
RECT rc;
HWND hnd = (HWND) lparam;
::GetClientRect(hnd, &rc);
HDC hdc= (HDC) wparam;
SetTextColor(hdc, RGB(0,0,0));
SetBkColor(hdc, bgColor);
return (int) hBrush;
}
case WM_DESTROY:
{
tlen_functions->CallTlenFunction(hInst, TLEN_REMOVE_DIALOG_HANDLE, (WPARAM) hInst, NULL);
DeleteObject(hBrush);
break;
}
}
return 0;
}
static int TlenPropertyPagesAction(WPARAM wParam,LPARAM lParam)
{
TlenPropertiesPageShowInfo *info = (TlenPropertiesPageShowInfo *) wParam;
switch (info->Action)
{
case TLEN_PROPERTIESPAGESHOW_ACTION_SHOW:
{
if (info->Page->OwnerData == NULL)
{
bgColor = info->bgColor;
prop_page = CreateDialog(hInst, MAKEINTRESOURCE(101), info->Handle, (DLGPROC)prefDialog);
info->Page->OwnerData = prop_page;
}
SetWindowPos(prop_page, 0, info->x, info->y, info->width, info->height, SWP_NOSIZE | SWP_NOZORDER);
ShowWindow(prop_page, SW_SHOW);
info->Icon.Bitmap = icon1;
strcpy(info->Caption, "Przyk│adowa PropertyPage");
strcpy(info->Description, "Bla bla bla, jaki£ opis");
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_HIDE:
{
HWND wnd = (HWND) info->Page->OwnerData;
if (wnd) ShowWindow(wnd, SW_HIDE);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_DESTROY:
{
HWND wnd = (HWND) info->Page->OwnerData;
if (wnd)
{
tlen_functions->CallTlenFunction(hInst, TLEN_REMOVE_DIALOG_HANDLE, (WPARAM) wnd, NULL);
DestroyWindow(prop_page);
info->Page->OwnerData = NULL;
prop_page = NULL;
}
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_OK:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_OK", "", MB_OK);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_APPLY:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_APPLY", "", MB_OK);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_CANCEL:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_CANCEL", "", MB_OK);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_ADD:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_ADD", "", MB_OK);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_SEARCH:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_SEARCH", "", MB_OK);
return 0;
}
case TLEN_PROPERTIESPAGESHOW_ACTION_CONTACTCHANGE:
{
MessageBox(NULL, "TLEN_PROPERTIESPAGESHOW_ACTION_CONTACTCHANGE", "", MB_OK);
return 0;
}
}
return 0;
}
static int TlenOnAddPropertyPagesRequest(WPARAM wParam,LPARAM lParam)
{
TlenPropertiesWindowInfoDef *info = (TlenPropertiesWindowInfoDef *) wParam;
//teraz chcemy np. tylko dodawac zakladke do kontaktow tlenowych
if (strcmp(info->Contact.ProtocolID, PROTOCOL_ID_TLEN) != 0) return 0;
TlenPropertiesPageDefinition page;
InitializeStruct(page);
page.CallBackFunction = TlenPropertyPagesAction;
page.Flags = TLEN_PROPERTIESPAGE_FLAG_TLENCOLOR;
if (info->WindowType == TLEN_PROPERTIESWINDOW_WINDOWTYPE_PROPERTIES)
{
page.PageID = "MojPlugin/zakladka1";
page.Name = "Zak│adka 1 (edit)";
tlen_functions->CallTlenFunction(hInst, TLEN_PROPERTIES_PAGEADD, (WPARAM) &page, lParam);
}
else if (info->WindowType == TLEN_PROPERTIESWINDOW_WINDOWTYPE_ADDCONTACT)
{
page.PageID = "MojPlugin/zakladka2";
page.Name = "Zak│adka 2 (add)";
tlen_functions->CallTlenFunction(hInst, TLEN_PROPERTIES_PAGEADD, (WPARAM) &page, lParam);
}
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst=hinstDLL;
return TRUE;
}
__declspec(dllexport) TLENPLUGININFO* GetPluginInfo(DWORD tlenVersion)
{
return &pluginInfo;
}
__declspec(dllexport) int LoadPlugin(TLENPLUGINFUNCTIONS *functions)
{
icon1 = (HBITMAP) LoadImage(hInst, MAKEINTRESOURCE(104),IMAGE_BITMAP, 32, 32, NULL);
tlen_functions = functions;
AddPropertiesPageHookHandle = tlen_functions->HookTlenEvent(hInst, TLEN_PROPERTIES_EVENT_ADDPAGES, TlenOnAddPropertyPagesRequest);
return 0;
}
__declspec(dllexport) int UnloadPlugin(void)
{
tlen_functions->UnhookTlenEvent(hInst, AddPropertiesPageHookHandle);
if (prop_page)
{
DestroyWindow(prop_page);
}
DeleteObject(icon1);
return 0;
}